package com.zxy.study.utils;

import android.content.Context;

/**
 * @author : Shonn.Zhang
 * @email : shonn.zhang@mart.blue
 * @time : 2020/9/4 14:47
 * @desc :
 */
public class DimenUtils {

    /**
     * dp 转 px,四舍五入
     * @param context
     * @param dp
     * @return
     */
    public static int dpToPx(Context context,int dp){
        float density = context.getResources().getDisplayMetrics().density;
        return (int) (dp * density + 0.5);
    }
}
